package com.hbzjt2012.array;

import java.util.Arrays;

public class ArrayDemo06 {
    public static void main(String[] args) {
        int[] a = {2, 4, 342, 23, 53, 2111};
        System.out.println(a); //[I@13b6d03

        //打印数组元素
        System.out.println(Arrays.toString(a));

        printArray(a);
        System.out.println();

        Arrays.sort(a); //数组进行排序
        System.out.println(Arrays.toString(a));

//        Arrays.fill(a, 0);  //数组填充
        Arrays.fill(a, 2, 4, 0);
        System.out.println(Arrays.toString(a));
    }

    public static void printArray(int[] a){
        for (int i = 0; i < a.length; i++) {
            if (i == 0){
                System.out.print("[");
            }
            if (i == a.length - 1){
                System.out.print(a[i] + "]");
            }else {
                System.out.print(a[i] + ", ");
            }
        }
    }
}
